{% extends "base.html" %}
{% block title %}管理员面板{% endblock %}
{% block content %}
<div class="container">
    <h2 class="mb-4">用户管理</h2>
    <div class="table-responsive">
        <table class="table table-striped">
            <thead>
                <tr>
                    <th>ID</th>
                    <th>用户名</th>
                    <th>头像</th>
                    <th>注册时间</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                {% for user in users %}
                <tr>
                    <td>{{ user.id }}</td>
                    <td>
                        {% if user.is_admin %}
                        <span class="badge rounded-pill bg-danger" style="font-family: 'Microsoft YaHei', sans-serif; font-weight: bold;">管理员</span>
                        {% else %}
                        <span class="badge rounded-pill bg-success" style="font-family: 'Microsoft YaHei', sans-serif; font-weight: bold;">用户</span>
                        {% endif %}
                        <a href="{{ url_for('profile', username=user.username) }}" class="text-decoration-none" style="color: black;">{{ user.username }}</a>
                    </td>
                    <td>
                        <img src="{{ url_for('static', filename='avatars/' + user.avatar) }}" 
                             class="rounded-circle" width="32" height="32">
                    </td>
                    <td>{{ user.date_joined }}</td>
                    <td>
                        <form method="POST" action="{{ url_for('admin_delete_user', user_id=user.id) }}" 
                              style="display: inline;" 
                              onsubmit="return confirm('确定要删除该用户吗？');">
                            <button type="submit" class="btn btn-danger btn-sm">删除</button>
                        </form>
                    </td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
</div>
{% endblock %}